package
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.filters.BevelFilter;
	import flash.filters.DropShadowFilter;
	import flash.net.URLRequest;
	
	public class Card extends Loader
	{
		public var id:int;
		
		public var W:Number = 40;
		public var H:Number = 40;
		
		/**
		 * 游戏区域中的位置，以便判断路线
		 */
		public var i:int;
		public var j:int;
		
		/**
		 * 下一个被点击的图片
		 */
		public var TargetCard:Card;
		
		public var Path:Array = new Array();
		
		/**
		 * 是否被点击
		 */
		private var pressed:Boolean = false;
		/**
		 * 如果点击正确，连线
		 */
		public var line:Sprite = new Sprite();
		public function Card(id:int) {
			
			this.id = id;
			load(new URLRequest("images/" + id +".jpg"));
			
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}

		public function setIndex(a:int, b:int):void {
			i = a;
			j = b;
		}
		public function isPressed():void {
			pressed = true;
		}
		public function unPressed():void {
			pressed = false;
			this.filters = null;
		}
		public function onMouseOver(evt:MouseEvent):void {
			var blur:BevelFilter = new BevelFilter();
			var shadow:DropShadowFilter = new DropShadowFilter(10);
			var f:Array = new Array();
			f.push(blur);
			f.push(shadow);
			this.filters = f;
		}
		public function onMouseOut(evt:MouseEvent):void {
			if (pressed == false) {
				this.filters = null;
			}
		}
	}
}